package qdu.edu.com.fushanf4.service.search.country;


import org.apache.hadoop.mapreduce.Job;
import qdu.edu.com.fushanf4.service.count.TextIntWritableCountReducer;
import qdu.edu.com.fushanf4.utils.ConfigurationUtil;
import qdu.edu.com.fushanf4.utils.DriverUtil;

import java.io.IOException;

/**
 * 该类用来查找数据集中出现的国家名称
 *
 * 输入路径：/hadoop/service/search/country/input
 * 输出路径：/hadoop/service/search/country/output
 * 国家名称文件的输入路径：/hadoop/service/search/country/CountryNameInput
 */
public class SearchCountryDriver extends DriverUtil {

    public static final String COUNTRY_NAME_INPUT = "countryNameInput";

    @Override
    public Job runJob(String[] path) throws IOException {
        Job job = ConfigurationUtil.getJob();
        assert path.length == 3;
        job.getConfiguration().set(COUNTRY_NAME_INPUT,path[2]);

        job.setJarByClass(SearchCountryDriver.class);
        job .setMapperClass(SearchCountryMapper.class);
        TextIntWritableCountReducer.setReduceOfAll(job);

        ConfigurationUtil.setPathAndRunJob(new String[]{path[0], path[1]},job);
        return job;
    }
}
